package services

import (
	"fmt"
	"strconv"

	"jihe.common/protos/base_server/proto"
)

type FashionCheck struct {
}

//生产人体模型
func (s *FashionCheck) AveragePositon(positions []*proto.BaseFashionAlgorithm) (ret map[string]string) {
	var (
		zyxxSum float64
		zyxySum float64
		yyxxSum float64
		yyxySum float64
	)
	for _, v := range positions {
		zyxxFloat, _ := strconv.ParseFloat(v.Zyxx, 64)
		zyxxSum += zyxxFloat
		zyxyFloat, _ := strconv.ParseFloat(v.Zyxy, 64)
		zyxySum += zyxyFloat
		yyxxFloat, _ := strconv.ParseFloat(v.Yyxx, 64)
		yyxxSum += yyxxFloat
		yyxyFloat, _ := strconv.ParseFloat(v.Yyxy, 64)
		yyxySum += yyxyFloat
	}
	ret = make(map[string]string)
	ret["zyxx"] = fmt.Sprintf("%.6f", zyxxSum/float64(len(positions)))
	ret["zyxy"] = fmt.Sprintf("%.6f", zyxySum/float64(len(positions)))
	ret["yyxx"] = fmt.Sprintf("%.6f", yyxxSum/float64(len(positions)))
	ret["yyxy"] = fmt.Sprintf("%.6f", yyxySum/float64(len(positions)))
	return
}
